n, m = map(int, input().split())
nums = list(map(int, input().split()))


def main():
    cnt = 0
    if sum(nums) < m:
        return -1
    acc = 0
    elem_cnt = 0
    for s in nums:
        acc += s
        elem_cnt += 1
        if s >= m:
            cnt += elem_cnt - 1
            elem_cnt = 0
            acc = 0
    return cnt


print(main())
